package de.webalpha.parking.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@XmlRootElement
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "id"))
public class ParkingLot {

	@Id
	@GeneratedValue
	private Long id;

	@NotNull
	private String description;

	@OneToMany
	@JoinColumn(name="BOOKING_ID")
	private List<Booking> bookings;
	
	

	public ParkingLot() {
		super();
		// TODO Auto-generated constructor stub
	}

	public ParkingLot(Long id, String description) {
		this.id = id;
		this.description = description;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<Booking> getBookings() {
		return bookings;
	}

	public void setBookings(List<Booking> bookings) {
		this.bookings = bookings;
	}

	@Override
	public String toString() {
		return "" + id;
	}

	@Override
	public int hashCode() {
		return (id != null) ? (this.getClass().hashCode() + id.hashCode())
				: super.hashCode();
	}

	@Override
	public boolean equals(Object other) {
		return (other instanceof ParkingLot) && (id != null) ? id
				.equals(((ParkingLot) other).id) : (other == this);
	}

}
